package com.yanqu.road.entity.activity.jiuzhou.game;

import java.util.HashMap;
import java.util.Map;

/**
 * 战局的用户数据
 */
public class CrossJiuZhouGameUserData {

    private long userId;

    /**
     * 最后的战场数
     */
    private int lastGameRound;

    /**
     * 最后的回合数
     */
    private int lastBattleRound;

    /**
     * 血量上限
     */
    private int maxHp;

    /**
     * 剩余血量
     * 小于等于0直接淘汰
     */
    private int curHp;

    /**
     * 本战场总伤害
     */
    private int attackDamage;

    /**
     * 使用技能次数
     */
    private Map<Integer, Integer> useSkillCnt = new HashMap<>();

    /**
     * 玩家对战记录
     */
    private Map<Long, Integer> battleCnt = new HashMap<>();

    /**
     * 总的镜像对战次数
     */
    private int totalMirrorBattleCnt;

    /**
     * 镜像对战次数
     */
    private Map<Long, Integer> mirrorBattleCnt = new HashMap<>();

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public int getMaxHp() {
        return maxHp;
    }

    public void setMaxHp(int maxHp) {
        this.maxHp = maxHp;
    }

    public int getCurHp() {
        return curHp;
    }

    public void setCurHp(int curHp) {
        this.curHp = curHp;
    }

    public int getLastGameRound() {
        return lastGameRound;
    }

    public void setLastGameRound(int lastGameRound) {
        this.lastGameRound = lastGameRound;
    }

    public int getLastBattleRound() {
        return lastBattleRound;
    }

    public void setLastBattleRound(int lastBattleRound) {
        this.lastBattleRound = lastBattleRound;
    }

    public int getAttackDamage() {
        return attackDamage;
    }

    public void setAttackDamage(int attackDamage) {
        this.attackDamage = attackDamage;
    }

    public Map<Long, Integer> getBattleCnt() {
        return battleCnt;
    }

    public void setBattleCnt(Map<Long, Integer> battleCnt) {
        this.battleCnt = battleCnt;
    }

    public Map<Long, Integer> getMirrorBattleCnt() {
        return mirrorBattleCnt;
    }

    public void setMirrorBattleCnt(Map<Long, Integer> mirrorBattleCnt) {
        this.mirrorBattleCnt = mirrorBattleCnt;
    }

    public Map<Integer, Integer> getUseSkillCnt() {
        return useSkillCnt;
    }

    public void setUseSkillCnt(Map<Integer, Integer> useSkillCnt) {
        this.useSkillCnt = useSkillCnt;
    }

    public void incrementMirrorBattleCnt(Long opponentUserId) {
        // 增加对战次数
        this.mirrorBattleCnt.merge(opponentUserId, 1, Integer::sum);
        // 更新总和
        updateTotalMirrorBattleCnt();
    }

    public void incrementBattleCnt(Long opponentUserId) {
        // 增加对战次数
        this.battleCnt.merge(opponentUserId, 1, Integer::sum);
    }

    /**
     * 更新镜像总计数时
     */
    public void updateTotalMirrorBattleCnt() {
        this.totalMirrorBattleCnt = this.mirrorBattleCnt.values().stream().mapToInt(Integer::intValue).sum();
    }

    public int getTotalMirrorBattleCnt() {
        return totalMirrorBattleCnt;
    }


}
